﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using YiTu.DBUtility;
namespace TOUR.SZHOME.DAL
{
    /// <summary>
    /// 数据表Projects的数据操作类
    /// </summary>
    public partial class ProjectsDAL
    {
        #region ConstVariables
        private const string C_TABLE_NAME = "Projects";
        private const string C_SP_PROJECTS_FIELDS = "[XMID],[XMMC],[XMLB],[XMDZ],[XMTS],[XMXQ],[ZLHX],[KPSJ],[RZSJ],[ZXDH],[TDNX],[LHL],[RJL],[ZHS],[CWS],[JZMJ],[ZDMJ],[YSXKZ],[GCCJS],[KFS],[WYGS],[WYLX],[WYF],[YLSJ],[JZSJ],[JJ],[JGSM],[JTDT],[PTJT1],[PTJT2],[PTJT3],[PTJT4],[JTDTJS],[QYJS],[XMJT],[XMPT],[TST],[TSNR],[XMLBT],[XMQJT],[XMDT],[HXJS],[TGDZ]";
        private const string C_SP_PROJECTS_INSERT = "INSERT INTO [Projects]([XMMC],[XMLB],[XMDZ],[XMTS],[XMXQ],[ZLHX],[KPSJ],[RZSJ],[ZXDH],[TDNX],[LHL],[RJL],[ZHS],[CWS],[JZMJ],[ZDMJ],[YSXKZ],[GCCJS],[KFS],[WYGS],[WYLX],[WYF],[YLSJ],[JZSJ],[JJ],[JGSM],[JTDT],[PTJT1],[PTJT2],[PTJT3],[PTJT4],[JTDTJS],[QYJS],[XMJT],[XMPT],[TST],[TSNR],[XMLBT],[XMQJT],[XMDT],[HXJS],[TGDZ]) VALUES(@XMMC,@XMLB,@XMDZ,@XMTS,@XMXQ,@ZLHX,@KPSJ,@RZSJ,@ZXDH,@TDNX,@LHL,@RJL,@ZHS,@CWS,@JZMJ,@ZDMJ,@YSXKZ,@GCCJS,@KFS,@WYGS,@WYLX,@WYF,@YLSJ,@JZSJ,@JJ,@JGSM,@JTDT,@PTJT1,@PTJT2,@PTJT3,@PTJT4,@JTDTJS,@QYJS,@XMJT,@XMPT,@TST,@TSNR,@XMLBT,@XMQJT,@XMDT,@HXJS,@TGDZ);SET @XMID = SCOPE_IDENTITY();";
        private const string C_SP_PROJECTS_UPDATE = "UPDATE [Projects] SET [XMMC]=@XMMC,[XMLB]=@XMLB,[XMDZ]=@XMDZ,[XMTS]=@XMTS,[XMXQ]=@XMXQ,[ZLHX]=@ZLHX,[KPSJ]=@KPSJ,[RZSJ]=@RZSJ,[ZXDH]=@ZXDH,[TDNX]=@TDNX,[LHL]=@LHL,[RJL]=@RJL,[ZHS]=@ZHS,[CWS]=@CWS,[JZMJ]=@JZMJ,[ZDMJ]=@ZDMJ,[YSXKZ]=@YSXKZ,[GCCJS]=@GCCJS,[KFS]=@KFS,[WYGS]=@WYGS,[WYLX]=@WYLX,[WYF]=@WYF,[YLSJ]=@YLSJ,[JZSJ]=@JZSJ,[JJ]=@JJ,[JGSM]=@JGSM,[JTDT]=@JTDT,[PTJT1]=@PTJT1,[PTJT2]=@PTJT2,[PTJT3]=@PTJT3,[PTJT4]=@PTJT4,[JTDTJS]=@JTDTJS,[QYJS]=@QYJS,[XMJT]=@XMJT,[XMPT]=@XMPT,[TST]=@TST,[TSNR]=@TSNR,[XMLBT]=@XMLBT,[XMQJT]=@XMQJT,[XMDT]=@XMDT,[HXJS]=@HXJS,[TGDZ]=@TGDZ WHERE [XMID] = @XMID";
        private const string C_SP_PROJECTS_DELETE = "DELETE [Projects] WHERE [XMID] = @XMID";
        private const string C_SP_PROJECTS_GET = "SELECT [XMID],[XMMC],[XMLB],[XMDZ],[XMTS],[XMXQ],[ZLHX],[KPSJ],[RZSJ],[ZXDH],[TDNX],[LHL],[RJL],[ZHS],[CWS],[JZMJ],[ZDMJ],[YSXKZ],[GCCJS],[KFS],[WYGS],[WYLX],[WYF],[YLSJ],[JZSJ],[JJ],[JGSM],[JTDT],[PTJT1],[PTJT2],[PTJT3],[PTJT4],[JTDTJS],[QYJS],[XMJT],[XMPT],[TST],[TSNR],[XMLBT],[XMQJT],[XMDT],[HXJS],[TGDZ] FROM [Projects] WHERE [XMID] = @XMID";
        #endregion

        private static string ConnectionString
        {
            get
            {
                return System.Configuration.ConfigurationManager.ConnectionStrings["TravelProject"].ConnectionString;
            }
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        private ProjectsDAL() { }

        /// <summary>
        /// 向数据表中插入一条新记录
        /// </summary>
        /// <param name="entity">Entity.ProjectsEntity实体类</param>
        /// <remarks>如果表存在自增长字段，插入记录成功后自增长字段值会更新至实体</remarks>
        public static bool Insert(Entity.ProjectsEntity entity)
        {
            List<SqlParameter> commandParms = new List<SqlParameter>();
            SqlParameter id_XMID = SqlHelper.CreateParam("@XMID", SqlDbType.Int, 0, ParameterDirection.Output, null);
            commandParms.Add(id_XMID);
            commandParms.Add(SqlHelper.CreateParam("@XMMC", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMMC));
            commandParms.Add(SqlHelper.CreateParam("@XMLB", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMLB));
            commandParms.Add(SqlHelper.CreateParam("@XMDZ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMDZ));
            commandParms.Add(SqlHelper.CreateParam("@XMTS", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMTS));
            commandParms.Add(SqlHelper.CreateParam("@XMXQ", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMXQ));
            commandParms.Add(SqlHelper.CreateParam("@ZLHX", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.ZLHX));
            commandParms.Add(SqlHelper.CreateParam("@KPSJ", SqlDbType.NVarChar, 15, ParameterDirection.Input, entity.KPSJ));
            commandParms.Add(SqlHelper.CreateParam("@RZSJ", SqlDbType.NVarChar, 15, ParameterDirection.Input, entity.RZSJ));
            commandParms.Add(SqlHelper.CreateParam("@ZXDH", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZXDH));
            commandParms.Add(SqlHelper.CreateParam("@TDNX", SqlDbType.NVarChar, 20, ParameterDirection.Input, entity.TDNX));
            commandParms.Add(SqlHelper.CreateParam("@LHL", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.LHL));
            commandParms.Add(SqlHelper.CreateParam("@RJL", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.RJL));
            commandParms.Add(SqlHelper.CreateParam("@ZHS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZHS));
            commandParms.Add(SqlHelper.CreateParam("@CWS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.CWS));
            commandParms.Add(SqlHelper.CreateParam("@JZMJ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.JZMJ));
            commandParms.Add(SqlHelper.CreateParam("@ZDMJ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZDMJ));
            commandParms.Add(SqlHelper.CreateParam("@YSXKZ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.YSXKZ));
            commandParms.Add(SqlHelper.CreateParam("@GCCJS", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.GCCJS));
            commandParms.Add(SqlHelper.CreateParam("@KFS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.KFS));
            commandParms.Add(SqlHelper.CreateParam("@WYGS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.WYGS));
            commandParms.Add(SqlHelper.CreateParam("@WYLX", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.WYLX));
            commandParms.Add(SqlHelper.CreateParam("@WYF", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.WYF));
            commandParms.Add(SqlHelper.CreateParam("@YLSJ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.YLSJ));
            commandParms.Add(SqlHelper.CreateParam("@JZSJ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.JZSJ));
            commandParms.Add(SqlHelper.CreateParam("@JJ", SqlDbType.Decimal, 0, ParameterDirection.Input, entity.JJ));
            commandParms.Add(SqlHelper.CreateParam("@JGSM", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.JGSM));
            commandParms.Add(SqlHelper.CreateParam("@JTDT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.JTDT));
            commandParms.Add(SqlHelper.CreateParam("@PTJT1", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.PTJT1));
            commandParms.Add(SqlHelper.CreateParam("@PTJT2", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.PTJT2));
            commandParms.Add(SqlHelper.CreateParam("@PTJT3", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.PTJT3));
            commandParms.Add(SqlHelper.CreateParam("@PTJT4", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.PTJT4));
            commandParms.Add(SqlHelper.CreateParam("@JTDTJS", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.JTDTJS));
            commandParms.Add(SqlHelper.CreateParam("@QYJS", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.QYJS));
            commandParms.Add(SqlHelper.CreateParam("@XMJT", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMJT));
            commandParms.Add(SqlHelper.CreateParam("@XMPT", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMPT));
            commandParms.Add(SqlHelper.CreateParam("@TST", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.TST));
            commandParms.Add(SqlHelper.CreateParam("@TSNR", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.TSNR));
            commandParms.Add(SqlHelper.CreateParam("@XMLBT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMLBT));
            commandParms.Add(SqlHelper.CreateParam("@XMQJT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMQJT));
            commandParms.Add(SqlHelper.CreateParam("@XMDT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMDT));
            commandParms.Add(SqlHelper.CreateParam("@HXJS", SqlDbType.NVarChar, 500, ParameterDirection.Input, entity.HXJS));
            commandParms.Add(SqlHelper.CreateParam("@TGDZ", SqlDbType.VarChar, 500, ParameterDirection.Input, entity.TGDZ));

            return SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, C_SP_PROJECTS_INSERT, commandParms) > 0 ? true : false;
            //entity.XMID = Convert.ToInt32(id_XMID.Value);
        }

        /// <summary>
        /// 获取数据库一条记录实体(根据主键条件)
        /// </summary>
        /// <param name="xMID">项目ID</param>
        /// <returns>Entity.ProjectsEntity实体类</returns>
        public static Entity.ProjectsEntity GetByXMID(int xMID)
        {
            Entity.ProjectsEntity entity = null;
            List<SqlParameter> commandParms = new List<SqlParameter>();
            commandParms.Add(SqlHelper.CreateParam("@XMID", SqlDbType.Int, 0, ParameterDirection.Input, xMID));

            using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, C_SP_PROJECTS_GET, commandParms))
            {
                if (reader.Read())
                {
                    entity = ConvertToEntityFromDataReader(reader);
                }
            }

            return entity;
        }

        /// <summary>
        /// 更新数据库中一条记录(根据主键条件)
        /// </summary>
        /// <param name="entity">Entity.ProjectsEntity实体类</param>
        public static bool Update(Entity.ProjectsEntity entity)
        {
            List<SqlParameter> commandParms = new List<SqlParameter>();

            commandParms.Add(SqlHelper.CreateParam("@XMID", SqlDbType.Int, 0, ParameterDirection.Input, entity.XMID));
            commandParms.Add(SqlHelper.CreateParam("@XMMC", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMMC));
            commandParms.Add(SqlHelper.CreateParam("@XMLB", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMLB));
            commandParms.Add(SqlHelper.CreateParam("@XMDZ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMDZ));
            commandParms.Add(SqlHelper.CreateParam("@XMTS", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.XMTS));
            commandParms.Add(SqlHelper.CreateParam("@XMXQ", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMXQ));
            commandParms.Add(SqlHelper.CreateParam("@ZLHX", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.ZLHX));
            commandParms.Add(SqlHelper.CreateParam("@KPSJ", SqlDbType.NVarChar, 15, ParameterDirection.Input, entity.KPSJ));
            commandParms.Add(SqlHelper.CreateParam("@RZSJ", SqlDbType.NVarChar, 15, ParameterDirection.Input, entity.RZSJ));
            commandParms.Add(SqlHelper.CreateParam("@ZXDH", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZXDH));
            commandParms.Add(SqlHelper.CreateParam("@TDNX", SqlDbType.NVarChar, 20, ParameterDirection.Input, entity.TDNX));
            commandParms.Add(SqlHelper.CreateParam("@LHL", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.LHL));
            commandParms.Add(SqlHelper.CreateParam("@RJL", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.RJL));
            commandParms.Add(SqlHelper.CreateParam("@ZHS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZHS));
            commandParms.Add(SqlHelper.CreateParam("@CWS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.CWS));
            commandParms.Add(SqlHelper.CreateParam("@JZMJ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.JZMJ));
            commandParms.Add(SqlHelper.CreateParam("@ZDMJ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.ZDMJ));
            commandParms.Add(SqlHelper.CreateParam("@YSXKZ", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.YSXKZ));
            commandParms.Add(SqlHelper.CreateParam("@GCCJS", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.GCCJS));
            commandParms.Add(SqlHelper.CreateParam("@KFS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.KFS));
            commandParms.Add(SqlHelper.CreateParam("@WYGS", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.WYGS));
            commandParms.Add(SqlHelper.CreateParam("@WYLX", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.WYLX));
            commandParms.Add(SqlHelper.CreateParam("@WYF", SqlDbType.NVarChar, 30, ParameterDirection.Input, entity.WYF));
            commandParms.Add(SqlHelper.CreateParam("@YLSJ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.YLSJ));
            commandParms.Add(SqlHelper.CreateParam("@JZSJ", SqlDbType.NVarChar, 50, ParameterDirection.Input, entity.JZSJ));
            commandParms.Add(SqlHelper.CreateParam("@JJ", SqlDbType.Decimal, 0, ParameterDirection.Input, entity.JJ));
            commandParms.Add(SqlHelper.CreateParam("@JGSM", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.JGSM));
            commandParms.Add(SqlHelper.CreateParam("@JTDT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.JTDT));
            commandParms.Add(SqlHelper.CreateParam("@PTJT1", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.PTJT1));
            commandParms.Add(SqlHelper.CreateParam("@PTJT2", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.PTJT2));
            commandParms.Add(SqlHelper.CreateParam("@PTJT3", SqlDbType.NVarChar, 100, ParameterDirection.Input, entity.PTJT3));
            commandParms.Add(SqlHelper.CreateParam("@PTJT4", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.PTJT4));
            commandParms.Add(SqlHelper.CreateParam("@JTDTJS", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.JTDTJS));
            commandParms.Add(SqlHelper.CreateParam("@QYJS", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.QYJS));
            commandParms.Add(SqlHelper.CreateParam("@XMJT", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMJT));
            commandParms.Add(SqlHelper.CreateParam("@XMPT", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.XMPT));
            commandParms.Add(SqlHelper.CreateParam("@TST", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.TST));
            commandParms.Add(SqlHelper.CreateParam("@TSNR", SqlDbType.NVarChar, 4000, ParameterDirection.Input, entity.TSNR));
            commandParms.Add(SqlHelper.CreateParam("@XMLBT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMLBT));
            commandParms.Add(SqlHelper.CreateParam("@XMQJT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMQJT));
            commandParms.Add(SqlHelper.CreateParam("@XMDT", SqlDbType.NVarChar, 200, ParameterDirection.Input, entity.XMDT));
            commandParms.Add(SqlHelper.CreateParam("@HXJS", SqlDbType.NVarChar, 500, ParameterDirection.Input, entity.HXJS));
            commandParms.Add(SqlHelper.CreateParam("@TGDZ", SqlDbType.VarChar, 500, ParameterDirection.Input, entity.TGDZ));

            return SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, C_SP_PROJECTS_UPDATE, commandParms) > 0 ? true : false;
        }

        /// <summary>
        /// 删除数据库中一条记录(根据主键条件)
        /// </summary>
        /// <param name="xMID">项目ID</param>
        public static bool Delete(int xMID)
        {
            List<SqlParameter> commandParms = new List<SqlParameter>();
            commandParms.Add(SqlHelper.CreateParam("@XMID", SqlDbType.Int, 0, ParameterDirection.Input, xMID));
            return SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, C_SP_PROJECTS_DELETE, commandParms) > 0 ? true : false;
        }

        /// <summary>
        /// 按条件查询数据表,返回DataTable类型数据
        /// </summary>
        /// <param name="whereClause">SQL条件语句(可为空)，不须带"Where"关键字</param>
        /// <param name="dataFields">需返回字段(不能为空,为"*"则返回所有字段)</param>
        /// <param name="orderBy">SQL排序语句(不能为空)，不须带"Order By"关键字</param>
        /// <param name="startRowIndex">记录开始索引，从0开始</param>
        /// <param name="maximumRows">返回记录数量</param>
        /// <returns>DataTable</returns>
        public static DataTable SearchDT(string whereClause, string dataFields, string orderBy, int startRowIndex, int maximumRows)
        {
            if (dataFields.Trim() == "*")
            {
                dataFields = C_SP_PROJECTS_FIELDS;
            }
            return SqlListHepler.Search(ConnectionString, C_TABLE_NAME, dataFields, whereClause, orderBy, startRowIndex, maximumRows);
        }


        /// <summary>
        /// 按条件查询数据表,返回 Entity.ProjectsEntity 数据集
        /// </summary>
        /// <param name="whereClause">SQL条件语句(可为空)，不须带"Where"关键字</param>
        /// <param name="orderBy">SQL排序语句(不能为空)，不须带"Order By"关键字</param>
        /// <param name="startRowIndex">记录开始索引，从0开始</param>
        /// <param name="maximumRows">返回记录数量</param>
        public static List<Entity.ProjectsEntity> Search(string whereClause, string orderBy, int startRowIndex, int maximumRows)
        {
            List<Entity.ProjectsEntity> list = new List<Entity.ProjectsEntity>();
            using (SqlDataReader reader = SqlListHepler.SearchDataReader(ConnectionString, C_TABLE_NAME, C_SP_PROJECTS_FIELDS, whereClause, orderBy, startRowIndex, maximumRows))
            {
                while (reader.Read())
                {
                    list.Add(ConvertToEntityFromDataReader(reader));
                }
            }
            return list;
        }

        /// <summary>
        /// 按条件查询数据表,返回DataTable类型数据
        /// </summary>
        /// <param name="whereClause">SQL条件语句(可为空)，不须带"Where"关键字</param>
        /// <param name="dataFields">需返回字段(不能为空,为"*"则返回所有字段)</param>
        /// <param name="orderBy">SQL排序语句(可为空)，不须带"Order By"关键字</param>
        /// <param name="rowsToReturn">返回记录数量</param>
        /// <returns>DataTable</returns>
        public static DataTable SearchDT(string whereClause, string dataFields, string orderBy, int rowsToReturn)
        {
            if (dataFields.Trim() == "*")
            {
                dataFields = C_SP_PROJECTS_FIELDS;
            }
            return SqlListHepler.Search(ConnectionString, C_TABLE_NAME, dataFields, whereClause, orderBy, rowsToReturn);
        }

        /// <summary>
        /// 按条件查询数据表,返回 Entity.ProjectsEntity 数据集
        /// </summary>
        /// <param name="whereClause">SQL条件语句(可为空)，不须带"Where"关键字</param>
        /// <param name="orderBy">SQL排序语句(可为空)，不须带"Order By"关键字</param>
        /// <param name="rowsToReturn">返回记录数量</param>
        public static List<Entity.ProjectsEntity> Search(string whereClause, string orderBy, int rowsToReturn)
        {
            List<Entity.ProjectsEntity> list = new List<Entity.ProjectsEntity>();
            using (SqlDataReader reader = SqlListHepler.SearchDataReader(ConnectionString, C_TABLE_NAME, C_SP_PROJECTS_FIELDS, whereClause, orderBy, rowsToReturn))
            {
                while (reader.Read())
                {
                    list.Add(ConvertToEntityFromDataReader(reader));
                }
            }
            return list;
        }

        /// <summary>
        /// 按条件获取记录数量
        /// </summary>
        /// <param name="whereClause">SQL条件语句(可为空)，不须带"Where"关键字</param>
        /// <returns>int整型数据</returns>
        public static int SearchCount(string whereClause)
        {
            return SqlListHepler.SearchCount(ConnectionString, C_TABLE_NAME, whereClause);
        }

        /// <summary>
        /// 转换DataRow类型数据记录为实体
        /// </summary>
        private static Entity.ProjectsEntity ConvertToEntityFromDataRow(DataRow row)
        {
            Entity.ProjectsEntity entity = new Entity.ProjectsEntity();
            entity.XMID = Convert.ToInt32(row["XMID"]);
            entity.XMMC = row["XMMC"].ToString();
            if (Convert.IsDBNull(row["XMLB"])) entity.XMLB = null; else entity.XMLB = row["XMLB"].ToString();
            entity.XMDZ = row["XMDZ"].ToString();
            entity.XMTS = row["XMTS"].ToString();
            if (Convert.IsDBNull(row["XMXQ"])) entity.XMXQ = null; else entity.XMXQ = row["XMXQ"].ToString();
            if (Convert.IsDBNull(row["ZLHX"])) entity.ZLHX = null; else entity.ZLHX = row["ZLHX"].ToString();
            if (Convert.IsDBNull(row["KPSJ"])) entity.KPSJ = null; else entity.KPSJ = row["KPSJ"].ToString();
            if (Convert.IsDBNull(row["RZSJ"])) entity.RZSJ = null; else entity.RZSJ = row["RZSJ"].ToString();
            if (Convert.IsDBNull(row["ZXDH"])) entity.ZXDH = null; else entity.ZXDH = row["ZXDH"].ToString();
            if (Convert.IsDBNull(row["TDNX"])) entity.TDNX = null; else entity.TDNX = row["TDNX"].ToString();
            if (Convert.IsDBNull(row["LHL"])) entity.LHL = null; else entity.LHL = row["LHL"].ToString();
            if (Convert.IsDBNull(row["RJL"])) entity.RJL = null; else entity.RJL = row["RJL"].ToString();
            if (Convert.IsDBNull(row["ZHS"])) entity.ZHS = null; else entity.ZHS = row["ZHS"].ToString();
            if (Convert.IsDBNull(row["CWS"])) entity.CWS = null; else entity.CWS = row["CWS"].ToString();
            if (Convert.IsDBNull(row["JZMJ"])) entity.JZMJ = null; else entity.JZMJ = row["JZMJ"].ToString();
            if (Convert.IsDBNull(row["ZDMJ"])) entity.ZDMJ = null; else entity.ZDMJ = row["ZDMJ"].ToString();
            if (Convert.IsDBNull(row["YSXKZ"])) entity.YSXKZ = null; else entity.YSXKZ = row["YSXKZ"].ToString();
            if (Convert.IsDBNull(row["GCCJS"])) entity.GCCJS = null; else entity.GCCJS = row["GCCJS"].ToString();
            if (Convert.IsDBNull(row["KFS"])) entity.KFS = null; else entity.KFS = row["KFS"].ToString();
            if (Convert.IsDBNull(row["WYGS"])) entity.WYGS = null; else entity.WYGS = row["WYGS"].ToString();
            if (Convert.IsDBNull(row["WYLX"])) entity.WYLX = null; else entity.WYLX = row["WYLX"].ToString();
            if (Convert.IsDBNull(row["WYF"])) entity.WYF = null; else entity.WYF = row["WYF"].ToString();
            if (Convert.IsDBNull(row["YLSJ"])) entity.YLSJ = null; else entity.YLSJ = row["YLSJ"].ToString();
            if (Convert.IsDBNull(row["JZSJ"])) entity.JZSJ = null; else entity.JZSJ = row["JZSJ"].ToString();
            if (Convert.IsDBNull(row["JJ"])) entity.JJ = null; else entity.JJ = Convert.ToDecimal(row["JJ"]);
            if (Convert.IsDBNull(row["JGSM"])) entity.JGSM = null; else entity.JGSM = row["JGSM"].ToString();
            if (Convert.IsDBNull(row["JTDT"])) entity.JTDT = null; else entity.JTDT = row["JTDT"].ToString();
            if (Convert.IsDBNull(row["PTJT1"])) entity.PTJT1 = null; else entity.PTJT1 = row["PTJT1"].ToString();
            if (Convert.IsDBNull(row["PTJT2"])) entity.PTJT2 = null; else entity.PTJT2 = row["PTJT2"].ToString();
            if (Convert.IsDBNull(row["PTJT3"])) entity.PTJT3 = null; else entity.PTJT3 = row["PTJT3"].ToString();
            if (Convert.IsDBNull(row["PTJT4"])) entity.PTJT4 = null; else entity.PTJT4 = row["PTJT4"].ToString();
            if (Convert.IsDBNull(row["JTDTJS"])) entity.JTDTJS = null; else entity.JTDTJS = row["JTDTJS"].ToString();
            if (Convert.IsDBNull(row["QYJS"])) entity.QYJS = null; else entity.QYJS = row["QYJS"].ToString();
            if (Convert.IsDBNull(row["XMJT"])) entity.XMJT = null; else entity.XMJT = row["XMJT"].ToString();
            if (Convert.IsDBNull(row["XMPT"])) entity.XMPT = null; else entity.XMPT = row["XMPT"].ToString();
            if (Convert.IsDBNull(row["TST"])) entity.TST = null; else entity.TST = row["TST"].ToString();
            if (Convert.IsDBNull(row["TSNR"])) entity.TSNR = null; else entity.TSNR = row["TSNR"].ToString();
            if (Convert.IsDBNull(row["XMLBT"])) entity.XMLBT = null; else entity.XMLBT = row["XMLBT"].ToString();
            if (Convert.IsDBNull(row["XMQJT"])) entity.XMQJT = null; else entity.XMQJT = row["XMQJT"].ToString();
            if (Convert.IsDBNull(row["XMDT"])) entity.XMDT = null; else entity.XMDT = row["XMDT"].ToString();
            if (Convert.IsDBNull(row["HXJS"])) entity.HXJS = null; else entity.HXJS = row["HXJS"].ToString();
            if (Convert.IsDBNull(row["TGDZ"])) entity.TGDZ = null; else entity.TGDZ = row["TGDZ"].ToString();

            return entity;
        }

        /// <summary>
        /// 转换SqlDataReader类型数据记录为实体
        /// </summary>
        private static Entity.ProjectsEntity ConvertToEntityFromDataReader(SqlDataReader reader)
        {
            Entity.ProjectsEntity entity = new Entity.ProjectsEntity();
            entity.XMID = Convert.ToInt32(reader["XMID"]);
            entity.XMMC = reader["XMMC"].ToString();
            if (Convert.IsDBNull(reader["XMLB"])) entity.XMLB = null; else entity.XMLB = reader["XMLB"].ToString();
            entity.XMDZ = reader["XMDZ"].ToString();
            entity.XMTS = reader["XMTS"].ToString();
            if (Convert.IsDBNull(reader["XMXQ"])) entity.XMXQ = null; else entity.XMXQ = reader["XMXQ"].ToString();
            if (Convert.IsDBNull(reader["ZLHX"])) entity.ZLHX = null; else entity.ZLHX = reader["ZLHX"].ToString();
            if (Convert.IsDBNull(reader["KPSJ"])) entity.KPSJ = null; else entity.KPSJ = reader["KPSJ"].ToString();
            if (Convert.IsDBNull(reader["RZSJ"])) entity.RZSJ = null; else entity.RZSJ = reader["RZSJ"].ToString();
            if (Convert.IsDBNull(reader["ZXDH"])) entity.ZXDH = null; else entity.ZXDH = reader["ZXDH"].ToString();
            if (Convert.IsDBNull(reader["TDNX"])) entity.TDNX = null; else entity.TDNX = reader["TDNX"].ToString();
            if (Convert.IsDBNull(reader["LHL"])) entity.LHL = null; else entity.LHL = reader["LHL"].ToString();
            if (Convert.IsDBNull(reader["RJL"])) entity.RJL = null; else entity.RJL = reader["RJL"].ToString();
            if (Convert.IsDBNull(reader["ZHS"])) entity.ZHS = null; else entity.ZHS = reader["ZHS"].ToString();
            if (Convert.IsDBNull(reader["CWS"])) entity.CWS = null; else entity.CWS = reader["CWS"].ToString();
            if (Convert.IsDBNull(reader["JZMJ"])) entity.JZMJ = null; else entity.JZMJ = reader["JZMJ"].ToString();
            if (Convert.IsDBNull(reader["ZDMJ"])) entity.ZDMJ = null; else entity.ZDMJ = reader["ZDMJ"].ToString();
            if (Convert.IsDBNull(reader["YSXKZ"])) entity.YSXKZ = null; else entity.YSXKZ = reader["YSXKZ"].ToString();
            if (Convert.IsDBNull(reader["GCCJS"])) entity.GCCJS = null; else entity.GCCJS = reader["GCCJS"].ToString();
            if (Convert.IsDBNull(reader["KFS"])) entity.KFS = null; else entity.KFS = reader["KFS"].ToString();
            if (Convert.IsDBNull(reader["WYGS"])) entity.WYGS = null; else entity.WYGS = reader["WYGS"].ToString();
            if (Convert.IsDBNull(reader["WYLX"])) entity.WYLX = null; else entity.WYLX = reader["WYLX"].ToString();
            if (Convert.IsDBNull(reader["WYF"])) entity.WYF = null; else entity.WYF = reader["WYF"].ToString();
            if (Convert.IsDBNull(reader["YLSJ"])) entity.YLSJ = null; else entity.YLSJ = reader["YLSJ"].ToString();
            if (Convert.IsDBNull(reader["JZSJ"])) entity.JZSJ = null; else entity.JZSJ = reader["JZSJ"].ToString();
            if (Convert.IsDBNull(reader["JJ"])) entity.JJ = null; else entity.JJ = Convert.ToDecimal(reader["JJ"]);
            if (Convert.IsDBNull(reader["JGSM"])) entity.JGSM = null; else entity.JGSM = reader["JGSM"].ToString();
            if (Convert.IsDBNull(reader["JTDT"])) entity.JTDT = null; else entity.JTDT = reader["JTDT"].ToString();
            if (Convert.IsDBNull(reader["PTJT1"])) entity.PTJT1 = null; else entity.PTJT1 = reader["PTJT1"].ToString();
            if (Convert.IsDBNull(reader["PTJT2"])) entity.PTJT2 = null; else entity.PTJT2 = reader["PTJT2"].ToString();
            if (Convert.IsDBNull(reader["PTJT3"])) entity.PTJT3 = null; else entity.PTJT3 = reader["PTJT3"].ToString();
            if (Convert.IsDBNull(reader["PTJT4"])) entity.PTJT4 = null; else entity.PTJT4 = reader["PTJT4"].ToString();
            if (Convert.IsDBNull(reader["JTDTJS"])) entity.JTDTJS = null; else entity.JTDTJS = reader["JTDTJS"].ToString();
            if (Convert.IsDBNull(reader["QYJS"])) entity.QYJS = null; else entity.QYJS = reader["QYJS"].ToString();
            if (Convert.IsDBNull(reader["XMJT"])) entity.XMJT = null; else entity.XMJT = reader["XMJT"].ToString();
            if (Convert.IsDBNull(reader["XMPT"])) entity.XMPT = null; else entity.XMPT = reader["XMPT"].ToString();
            if (Convert.IsDBNull(reader["TST"])) entity.TST = null; else entity.TST = reader["TST"].ToString();
            if (Convert.IsDBNull(reader["TSNR"])) entity.TSNR = null; else entity.TSNR = reader["TSNR"].ToString();
            if (Convert.IsDBNull(reader["XMLBT"])) entity.XMLBT = null; else entity.XMLBT = reader["XMLBT"].ToString();
            if (Convert.IsDBNull(reader["XMQJT"])) entity.XMQJT = null; else entity.XMQJT = reader["XMQJT"].ToString();
            if (Convert.IsDBNull(reader["XMDT"])) entity.XMDT = null; else entity.XMDT = reader["XMDT"].ToString();
            if (Convert.IsDBNull(reader["HXJS"])) entity.HXJS = null; else entity.HXJS = reader["HXJS"].ToString();
            if (Convert.IsDBNull(reader["TGDZ"])) entity.TGDZ = null; else entity.TGDZ = reader["TGDZ"].ToString();

            return entity;
        }

    }
}
